package com.tt.plat8.commons.ui;

import com.vaadin.ui.Table;

public class TableBuilder {

	public enum Sort {
		ASC, DESC
	}

	private final Table table;

	public TableBuilder() {
		table = new Table();
	}

	public TableBuilder column(String name, Class<?> clazz) {
		table.addContainerProperty(name, clazz, null);
		return this;
	}

	public TableBuilder sortBy(String name, Sort sort) {
		table.setSortContainerPropertyId(name);
		table.setSortAscending(sort == Sort.ASC);
		return this;
	}

	public TableBuilder selectableRows() {
		table.setSelectable(true);
		return this;
	}

	public Table build() {
		return table;
	}

}
